package com.zklh.leetcode.dynamic;

/**
 * 使用最小费用爬楼梯
 *
 * @author tongnan
 * @date 2025/9/24
 */
public class Solution746 {
    int[] minCostClimbingTraceCost;

    public int minCostClimbingStairs(int[] cost) {
        minCostClimbingTraceCost = new int[cost.length+1];
        for (int i = 2; i <= cost.length; i++) {
            minCostClimbingTraceCost[i] = Math.min(minCostClimbingTraceCost[i-1]+cost[i-1], minCostClimbingTraceCost[i-2]+cost[i-2]);
        }
        return minCostClimbingTraceCost[cost.length];
    }
}
